#include "vector2.h"
#include <math.h>

vector2::vector2(void)
{
	this->x = 0.0f;
	this->y = 0.0f;
}
vector2::vector2(const vector2 &a)
{
	this->x = a.x;
	this->y = a.y;
}
vector2::vector2(int x, int y)
{
	this->x = (float)(x);
	this->y = (float)(y);
}
vector2::vector2(uint x, uint y)
{
	this->x = (float)(x);
	this->y = (float)(y);
}
vector2::vector2(float x, float y)
{
	this->x = x;
	this->y = y;
}
vector2::~vector2(void)
{
}
float vector2::Length()
{
	return sqrt(pow(x,2) + pow(y,2));
}
vector2 vector2::Normalize()
{
	float mag = Length();
	return vector2(x/mag, y/mag);
}
vector2 vector2::Negate()
{
	return vector2(-x, -y);
}
vector2 vector2::operator*(float a)
{
	return vector2(x * a, y * a);
}
vector2 vector2::operator/(float a)
{
	return vector2(x / a, y / a);
}
vector2 vector2::operator+(const vector2 &b)
{
	return vector2(x + b.x, y + b.y);
}
vector2 vector2::operator-(const vector2 &b)
{
	return vector2(x - b.x, y - b.y);
}
vector2 vector2::operator-()
{
	return vector2(-x, -y);
}
vector2 vector2::Rotate(float zRotation)
{
	float sinRot = sin(zRotation);
	float cosRot = cos(zRotation);
	return vector2(cosRot*x + (-sinRot)*y, sinRot*x + cosRot*y);
}
vector2 vector2::Translate(float xTrans, float yTrans)
{
	return vector2(x+xTrans, y+yTrans);
}
vector2 vector2::Translate(vector2 trans)
{
	return vector2(x + trans.x, y + trans.y);
}
vector2 vector2::Scale(float uniScale)
{
	return vector2(x*uniScale, y*uniScale);
}
vector2 vector2::Scale(float xScale, float yScale)
{
	return vector2(x*xScale, y*yScale);
}